-
Notifications
You must be signed in to change notification settings - Fork 30
Add SNI, NOISE, CERTHASH, WEBRTC, WEBRTC-DIRECT in py-multiaddr #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@acul71: Can you please take a look why these checks are failing with my changes, I am not understanding. |
|
Added the certhash protcol, along with the test-suite |
|
Added webrtc and webrtc-direct in 4507543, along with maddr test cases in test_multiaddr.py |
c82bbc9 to
aa2202d
Compare
PR #97 Review: Add SNI, NOISE, CERTHASH, WEBRTC, WEBRTC-DIRECT in py-multiaddrSummaryThis PR adds support for 5 new multiaddr protocols to py-multiaddr:
The implementation follows the go-multiaddr reference implementation and includes comprehensive test coverage. Detailed Review✅ Protocol Codes VerificationAll protocol codes match the go-multiaddr reference implementation:
✅ Protocol ConfigurationsProtocol configurations correctly match the go-multiaddr implementation:
✅ CERTHASH ImplementationThe CERTHASH codec implementation correctly matches the go-multiaddr transcoder: Go Implementation: func certHashStB(s string) ([]byte, error) {
_, data, err := multibase.Decode(s)
if err != nil {
return nil, err
}
if _, err := mh.Decode(data); err != nil {
return nil, err
}
return data, nil
}
func certHashBtS(b []byte) (string, error) {
return multibase.Encode(multibase.Base64url, b)
}
func validateCertHash(b []byte) error {
_, err := mh.Decode(b)
return err
}Python Implementation: def to_bytes(self, proto: Any, string: str) -> bytes:
decoded_bytes = multibase.decode(string)
self.validate(decoded_bytes)
return decoded_bytes
def to_string(self, proto: Any, buf: bytes) -> str:
self.validate(buf)
encoded_string = multibase.encode("base64url", buf)
return encoded_string.decode("utf-8")
def validate(self, b: bytes) -> None:
multihash.decode(b)Analysis:
✅ Test CoverageComprehensive test coverage has been added: Multiaddr String Tests# SNI test case
"/ip4/127.0.0.1/tcp/443/tls/sni/example.com/http/http-path/foo"
# NOISE test case
"/ip4/127.0.0.1/tcp/127/noise"
# CERTHASH test cases
"/ip4/127.0.0.1/udp/1234/quic-v1/webtransport/certhash/b2uaraocy6yrdblb4sfptaddgimjmmpy"
"/ip4/127.0.0.1/udp/1234/quic-v1/webtransport/certhash/b2uaraocy6yrdblb4sfptaddgimjmmpy/certhash/zQmbWTwYGcmdyK9CYfNBcfs9nhZs17a6FQ4Y8oea278xx41"
# WEBRTC test cases
"/ip4/127.0.0.1/tcp/127/webrtc-direct"
"/ip4/127.0.0.1/tcp/127/webrtc"CERTHASH Codec Tests
✅ Code Quality
✅ DependenciesThe implementation correctly uses existing dependencies:
Issues Found✅ Fixed Issues
|
|
@lla-dane : Great contribution. Appreciate your efforts. Wish if you could resolve the merge conflicts. Looking forward to arriving at a good conclusion on this important PR. Will re-run the CI/CD pipeline after the merge conflicts are resolved. Can you please open a discussion page with updated notes and screencast on testing the PR? We can take up the examples in another PR. @acul71 : Thank you so much Luca for reviewing the PR. Appreciate your support. |
- Added the protocol utils in certhash.py - Added the internal logic test suite in test_protocols.py - Added the certhash multiaddr test cases in test_multiaddr.py
- Added the protocols in the registry in protcols.py - Added the maddr test cases in test_multiaddr.py
- Fix multihash.encode() to multihash.digest().encode() in tests - Rename newsfragment from 97.feature.rst to 181.feature.rst to match issue #181 - All tests now pass with correct multihash API usage
- Use multihash.encode() instead of multihash.digest().encode() - This matches the py-multihash library API used in CI - All tests now pass with correct multihash library version
|
Fixed the merge conflicts. @seetadev. Lets see the CI run. |
|
@lla-dane : This is indeed, fantastic. CI/CD issues resolved. Please spend sometime on these minor issues observed earlier: Test Function Naming: The test function test_certhash_memory_validate_function() has an incorrect name - it should be test_certhash_validate_function() since it's testing the certhash codec, not memory. Missing Documentation: The new protocols could benefit from documentation in the main module docstring or examples. Please add summarized documentation here. We will follow it up in details on a discussion page. The PR is almost ready for a final review + merge. |
Tracks: multiformats/multiaddr#181
Added
SNI, NOISE, CERTHASH, WEBRTC, WEBRTC-DIRECTprotocol in py-multiaddr in reference with go-multiaddrSNIhad the same codec configs as DNS in go-multiaddrSo just added this line in the protocol registry
Did the same thing with
NOISEAdded the
CERTHASHprotocol as per go implementation